package com.bdqn.t382.dao;

import com.bdqn.t382.sz.BusinessService;
import com.bdqn.t382.sz.BusinessServiceImpl;
import com.bdqn.t382.sz.LoggingInvocationHandler;

import java.lang.reflect.Proxy;

public class JDKProxyDemo {
    public static void main(String[] args) {
        BusinessService businessService = new BusinessServiceImpl();
        BusinessService proxyInstance = (BusinessService) Proxy.newProxyInstance(
                businessService.getClass().getClassLoader(),
                businessService.getClass().getInterfaces(),
                new LoggingInvocationHandler(businessService)
        );

        proxyInstance.performBusinessOperation();
    }
}
